<html>
<head>
<title>Tutorial 1 Stage 5 - Including database graphics into the report and generating drilldowns</title>
<link rel="stylesheet" type="text/css" href="../media/style.css">
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
    <td width="100%">
			<table width="100%" height="78" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="topnav">
			<tr>
				<!-- Header Side -->
				<td width="17">
					<img height="78" src="media/reportico100.png"/>
				</td>
				<td align="right"></td>
				<td align="center">
					<table width="100%" height="60" border="0" align="left" cellpadding="0" cellspacing="0">
						<tr>
							<td valign="top" align="left">
							<img src="media/repbanner.png"/></td>
							</td>
						</tr>
						<tr>
							<td align="center" valign="bottom" class="topmenucell">
								<nobr>
								&nbsp;
								</nobr>
							</td>
						</tr>
					</table>
				</td>
				<td width="103" class="toplogincell">
					&nbsp;
				</td>
			</tr>
			</table>
</td>
  </tr>
  <!--tr>
    <td class="header_top">reportico</td>
  </tr-->
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td class="header_menu">
  		  [ <a href="../classtrees_reportico.html" class="menu">class tree: reportico</a> ]
		  [ <a href="../elementindex_reportico.html" class="menu">index: reportico</a> ]
		  [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td class="header_line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="200" class="menu">
      <b>Packages:</b><br />
              <a href="../li_reportico.html">reportico</a><br />
            <br /><br />
		<b>Tutorials/Manuals:</b><br />
					<strong>Package-level:</strong>
							<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.pkg.html">Reportico Tutorial And User Manual</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.manual.pkg.html">Reportico User Manual</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.quickstart.pkg.html">Reportico Installation</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.gettingstarted.pkg.html">Getting Started</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.structure.pkg.html">Reportico Installation Structure</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.using.pkg.html">Configuring Reportico - System Parameters</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.embedding.pkg.html">Embedding Reportico</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.security.pkg.html">Reportico Security</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.language.pkg.html">Language Support</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.projects.pkg.html">Projects</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.importlink.pkg.html">Importing and linking from reports</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.menus.pkg.html">Report Menus</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.prepare.pkg.html">Report Preparation and Execution</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.design.pkg.html">Report Design Mode</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.format.pkg.html">The Design Format Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.customcode.pkg.html">Custom Source Code</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.qrydet.pkg.html">The Query Details Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.assign.pkg.html">The Assignments Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.criteria.pkg.html">The Criteria Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.output.pkg.html">The Output Menu</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.webservices.pkg.html">Turning Reports into Web Services (currently unavailable)</a>
</ul>
</li></ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.faq.pkg.html">Reportico FAQ</a>
</ul>
</li></ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.howto.pkg.html">Reportico Tutorial</a>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1.pkg.html">Tutorial No.1 - The Film Listing Report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_1.pkg.html">Tutorial 1 Stage 1 - Creating a basic report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_2.pkg.html">Tutorial 1 Stage 2 - Creating User Entry Criteria</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_3.pkg.html">Tutorial 1 Stage 3 - Working with expressions using assignments</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_4.pkg.html">Tutorial 1 Stage 4 - Working with groups</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial1_5.pkg.html">Tutorial 1 Stage 5 - Including database graphics into the report and generating drilldowns</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial2_1.pkg.html">Tutorial 2 - Creating the loan history report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial3_1.pkg.html">Tutorial 3 - The Monthly Returns Report</a>
</ul>
<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.tutorial4_1.pkg.html">Tutorial 4 - The Late Returns Summary report</a>
</ul>
</li></ul>
</li></ul>

							<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.appendix1.pkg.html">Appendix 1 - Reportico Project Configuration parameters</a>
</ul>

							<ul>
	<li type="square"><a href="../reportico/tutorial_reportico.appendix2.pkg.html">Appendix 2 - Reportico URL request parameters</a>
</ul>

									                        <b>Files:</b><br />
      	  <div class="package">
			<a href="../reportico/_reportico.php.html">		reportico.php
		</a><br>
	  </div><br />
      
                </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" align="left" valign="bottom"><a href=
"../reportico/tutorial_reportico.tutorial1_4.pkg.html">Prev</a></td>
<td width="80%" align="center" valign="bottom"></td>
<td width="10%" align="right" valign="bottom"><a href=
"../reportico/tutorial_reportico.tutorial2_1.pkg.html">Next</a></td>
</tr>
</table>
<span><a name="assign."></a><h2 class="title">Tutorial 1 Stage 5 - Including database graphics into the report and generating drilldowns</h2><p>In this stage you will learn how to :-
	<ol><li><p>Create an image assignment</p></li></ol></p>
   <a name="tut1_5_run"></a><h3 class="title">Beginning the Tutorial 1 Stage 5 Report</h3><p>Select <strong>Film Listing - Tutorial 1 Stage 5</strong> from the tutorials menu (Alternatively you can point your browser at the URL <strong>http://{SERVER_ADDRESS}/{REPORTICO_INSTALL_DIRECTORY}/run.php?project=tutorials&amp;execute_mode=PREPARE&amp;xmlin=tut1_5_films.xml</strong>). You are now ready to start the final stage of this tutorial.</p>
<p>Note that the starting point for this stage follows directly from stage 4 and is virtually the same report that you created in stage 4.</p><hr />
   <a name="tut1_5_dbimage"></a><h3 class="title">Create an image assignment</h3><p>To include the image in the report, you must create a new report column and then create assignment to it that will fetch the database image based on the country code.</p>
   <p>Select the <strong>Assignments</strong> tab and add a new assignment. Find the <strong>Database Graphic Wizard</strong> and open this up.  Then set the parameters as follows:-
<table border = "1"><colgroup span = "1"/><thead><td></td>
  <td>Parameter</td>
  <td>Value</td>
  <td>Description</td></thead>
<tbody><tr><td>1.</td>
  <td>Assign To New Column</td>
  <td>flag</td>
  <td>Creates a new flag column</td></tr>
<tr><td>2.</td>
  <td>Column Containing Graphic</td>
  <td>flag</td>
  <td>The column containing the graphic image</td></tr>
<tr><td>3.</td>
  <td>Table Containing Graphic</td>
  <td>reptut_country</td>
  <td>The table containing the graphic image</td></tr>
<tr><td>4.</td>
  <td>Column To Match Report Graphic</td>
  <td>country_code</td>
  <td>The column in the image table that is queried</td></tr>
<tr><td>5.</td>
  <td>Report Graphic Width</td>
  <td>50</td>
  <td>The width in pixels to display the image in the report</td></tr>
<tr><td>6.</td>
  <td>Graphic Report Column</td>
  <td>country_code</td>
  <td>The report column which used to look up the row in the image table</td></tr></tbody></table></p>
   <p>Press <strong>Ok</strong> and notice that the expression is set to an <strong>image_query</strong> function call which shows the select statement that will be run to fetch the image.</p><hr />
   <a name="tut1_2_check"></a><h3 class="title">Checking Your Report</h3><p>Run the report. Notice that the report output includes a flag for each country. The flag image for each country is held in the <strong>country</strong> table in column <strong>flag</strong></p><hr />
   <a name="tut1_5_drilldown"></a><h3 class="title">Create a drilldown link to another report</h3><p>To turn one of the columns into a clickable link which will display another report based on the clicked column. In this case we are going to convert the film title into a clickable link that will open up the loan history report and show all dates that hte film was hired and the members who hired it.</p>
   <p>Enter report design mode and select the <strong>Assignments</strong> tab and add a new assignment by clicking the Add tab. Wr</p>
   <p>Now we have the column, select the <strong>Assignments</strong> tab and add a new assignemnt by pressing <strong>Add</strong> and click on the new Assignment button that appears at the bottom of the assignment buttons. Set the <strong>Assign To</strong> field to be <strong>title</strong> as that is the column we are going to turn into a clickable link. Now find the <strong>Drilldown Wizard</strong> and open that up, set the drilldown report name to be <strong>tut2_loanhistory.xml</strong> as that is the report we are going to drill into. Click the <strong>Ok</strong> button next to the <strong>Drilldown Report</strong> line and a list of the criteria items in the Loan History report will appear. Now select the list box labeled <strong>Drilldown Column for Criteria film</strong> and choose film_id. So what we are doing is saying that the film_id column in this report shoudl be passed to the film criteria item in the Loan History report when the link is clicked. Press the <strong>Ok</strong> button on the right of the drill down options. Now you have an assignment expression of</p>
<p><code><pre>
    embed_hyperlink('Drill', '{URL_TO_SITE}/run.php?/xmlin=tut2_loanhistory.xml&amp;execute_mode=EXECUTE&amp;target_format=HTML&amp;target_show_body=1&amp;project=tutorials&amp;MANUAL_film='.{film_id}.'')
</pre></code></p>
<p>We are not finished yet. There are 2 things to do to this assignment.</p>
<p>Firstly the link this function will create will be labelled <strong>Drill</strong>. We want to the link to appear as the film title. So change the assisngment to (leaving the appropriate value for URL_TO_SITE}</p>
<p><code><pre>
    embed_hyperlink({title}, '{URL_TO_SITE}/run.php?xmlin=tut2_loanhistory.xml&amp;execute_mode=EXECUTE&amp;target_format=HTML&amp;target_show_body=1&amp;project=tutorials&amp;MANUAL_film='.{film_id}.'')
</pre></code></p>
<p>You should try running the report now, to check your link appears in the output. Also the link should work in PDF output!! 
However the Loan History report by default shows loans taken out between the first of this month and today. It is quite likely that the films you click on may not have been loaned out. Therefore we can change the link to get details of films taken out for a longer period.  So lets change the link to report on the period between the first of the last year and today.</p>
<p>To do this edit the same assignment and change the assignment to (leaving the appropriate value for URL_TO_SITE}</p>
<p><code><pre>
    embed_hyperlink({title}, '{URL_TO+SITE}/run.php?xmlin=tut2_loanhistory.xml&amp;execute_mode=EXECUTE&amp;target_format=HTML&amp;target_show_body=1&amp;project=tutorials&amp;MANUAL_loanDate_FROMDATE=FIRSTOFLASTYEAR&amp;MANUAL_loanDate_TODAY&amp;MANUAL_film='.{film_id}.'')
</pre></code></p><hr />
   <a name="tut1_2_check"></a><h3 class="title">Checking Your Report</h3><p>Run the report. See that the link opens up a Loan History report and shows loans since the first of last month for the chosen film.</p><hr /></span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="../reportico/tutorial_reportico.tutorial1_4.pkg.html">Prev</a></td>
<td width="34%" align="center" valign="top"><a href=
"../reportico/tutorial_reportico.howto.pkg.html">Up</a></td>
<td width="33%" align="right" valign="top"><a href=
"../reportico/tutorial_reportico.tutorial2_1.pkg.html">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top">Tutorial 1 Stage 4 - Working with groups</td>
<td width="34%" align="center" valign="top">Reportico Tutorial</td>
<td width="33%" align="right" valign="top">Tutorial 2 - Creating the loan history report</td>
</tr>
</table>
        <div class="credit">
		    <hr />
		    Documentation generated on Mon, 09 Jun 2014 18:10:08 +0100 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.3</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>